/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function ImageEngine() {
    if ( ImageEngine.caller != ImageEngine.getInstance ) {  
        throw new Error("This object cannot be instanciated");  
    }
    
    console.log("Starting loading images");
    
    var _assetsPath, _manifest, _preload;
    var _init = function(){
        _assetsPath = PATH_IMG;
        _manifest = [
        {
            src:_assetsPath+"background.png", 
            id:"background", 
            data:1
        },

        {
            src:_assetsPath+"centerBase1.png", 
            id:"centerBase1", 
            data:1
        },

        {
            src:_assetsPath+"centerBase2.png", 
            id:"centerBase2", 
            data:1
        },

        {
            src:_assetsPath+"centerBase3.png", 
            id:"centerBase3", 
            data:1
        },

        {
            src:_assetsPath+"centerBase4.png", 
            id:"centerBase4", 
            data:1
        },

        {
            src:_assetsPath+"packet1.png", 
            id:"packet1", 
            data:1
        },

        {
            src:_assetsPath+"packet2.png", 
            id:"packet2", 
            data:1
        },

        {
            src:_assetsPath+"packet3.png", 
            id:"packet3", 
            data:1
        },

        {
            src:_assetsPath+"packet4.png", 
            id:"packet4", 
            data:1
        },

        {
            src:_assetsPath+"node.png", 
            id:"node", 
            data:1
        },

        {
            src:_assetsPath+"pipe.png", 
            id:"pipe", 
            data:1
        },

        {
            src:_assetsPath+"haloCenterBase1.png", 
            id:"haloCenterBase1", 
            data:1
        },

        {
            src:_assetsPath+"haloCenterBase2.png", 
            id:"haloCenterBase2", 
            data:1
        },

        {
            src:_assetsPath+"haloCenterBase3.png", 
            id:"haloCenterBase3", 
            data:1
        },

        {
            src:_assetsPath+"haloCenterBase4.png", 
            id:"haloCenterBase4", 
            data:1
        },

        {
            src:_assetsPath+"centerBase.png", 
            id:"centerBaseDefault", 
            data:1
        },
        {
            src:_assetsPath+"packet0.png", 
            id:"packet0", 
            data:1
        },
        {
            src:_assetsPath+"spellKnowledgeColorless.png", 
            id:"spellKnowledgeColorless", 
            data:1
        },
        {
            src:_assetsPath+"spellFreeze.png", 
            id:"spellFreeze", 
            data:1
        },
        {
            src:_assetsPath+"spellKnowledgeHeal.png", 
            id:"spellKnowledgeHeal", 
            data:1
        },
        {
            src:_assetsPath+"spellCenterBaseHeal.png", 
            id:"spellCenterBaseHeal", 
            data:1
        },
        {
            src:_assetsPath+"pause.png", 
            id:"pause", 
            data:1
        },
        {
            src:_assetsPath+"fxmute.png", 
            id:"fxmute", 
            data:1
        },
        {
            src:_assetsPath+"music_mute.png", 
            id:"music_mute", 
            data:1
        }
            
        ];
        _preload = new createjs.PreloadJS();
        _preload.onComplete = function(){
            console.log("ImageEngine should have finished loading");
        }
        _preload.loadManifest(_manifest, true);
    };
    
    _init();
    
    this.getBackground = function(){
        var img = new Image();
        img.src = _preload.getResult("background").src;
        return img;
    };
    this.getCenterBase1 = function(){
        var img = new Image();
        img.src = _preload.getResult("centerBase1").src;
        return img;
    };
    this.getCenterBase2 = function(){
        var img = new Image();
        img.src = _preload.getResult("centerBase2").src;
        return img;
    };
    this.getCenterBase3 = function(){
        var img = new Image();
        img.src = _preload.getResult("centerBase3").src;
        return img;
    };
    this.getCenterBase4 = function(){
        var img = new Image();
        img.src = _preload.getResult("centerBase4").src;
        return img;
    };
    this.getPacket0 = function(){
        var img = new Image();
        img.src = _preload.getResult("packet0").src;
        return img;
    };
    this.getPacket1 = function(){
        var img = new Image();
        img.src = _preload.getResult("packet1").src;
        return img;
    };
    this.getPacket2 = function(){
        var img = new Image();
        img.src = _preload.getResult("packet2").src;
        return img;
    };
    this.getPacket3 = function(){
        var img = new Image();
        img.src = _preload.getResult("packet3").src;
        return img;
    };
    this.getPacket4 = function(){
        var img = new Image();
        img.src = _preload.getResult("packet4").src;
        return img;
    };
    this.getDefaultCenterBase = function(){
        var img = new Image();
        img.src = _preload.getResult("centerBaseDefault").src;
        return img;
    };
    this.getNode = function(){
        var img = new Image();
        img.src = _preload.getResult("node").src;
        return img;
    };
    this.getPipe = function(){
        var img = new Image();
        img.src = _preload.getResult("pipe").src;
        return img;
    };
    this.getHaloCenterBase1 = function(){
        var img = new Image();
        img.src = _preload.getResult("haloCenterBase1").src;
        return img;
    };
    this.getHaloCenterBase2 = function(){
        var img = new Image();
        img.src = _preload.getResult("haloCenterBase2").src;
        return img;
    };
    this.getHaloCenterBase3 = function(){
        var img = new Image();
        img.src = _preload.getResult("haloCenterBase3").src;
        return img;
    };
    this.getHaloCenterBase4 = function(){
        var img = new Image();
        img.src = _preload.getResult("haloCenterBase4").src;
        return img;
    };
    this.getHaloCenterBase5 = function(){
        var img = new Image();
        img.src = _preload.getResult("haloCenterBase5").src;
        return img;
    };
    this.getSpellKnowledgeColorless = function(){
        var img = new Image();
        img.src = _preload.getResult("spellKnowledgeColorless").src;
        return img;
    };
    this.getSpellFreeze = function(){
        var img = new Image();
        img.src = _preload.getResult("spellFreeze").src;
        return img;
    };
    this.getSpellAddKnowledgePV = function(){
        var img = new Image();
        img.src = _preload.getResult("spellKnowledgeHeal").src;
        return img;
    };
    this.getSpellAddResearchCenterPV = function(){
        var img = new Image();
        img.src = _preload.getResult("spellCenterBaseHeal").src;
        return img;
    };
    this.getPause = function(){
        var img = new Image();
        img.src = _preload.getResult("pause").src;
        return img;
    };
    this.getFxMute = function(){
        var img = new Image();
        img.src = _preload.getResult("fxmute").src;
        return img;
    };
    this.getMusicMute = function(){
        var img = new Image();
        img.src = _preload.getResult("music_mute").src;
        return img;
    };
    
};

ImageEngine.sharedInstance = null;
ImageEngine.getInstance = function(){
    if(this.sharedInstance == null){
        this.sharedInstance = new ImageEngine();
    }
    return this.sharedInstance;
}
